package com.app.piemoment;

import java.util.ArrayList;

import android.graphics.Color;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.ListView;
import android.widget.TextView;

import com.app.piemoment.adapter.NotifyAdapter;
import com.app.piemoment.entity.NotifyEntity;

public class NotifyActivity extends BaseActivity implements OnClickListener {

	private ListView listView;
	private NotifyAdapter adapter;
	private TextView tips_text;
	
	
	public NotifyActivity() {
		mainViewId = R.layout.notify;
	}
	
	@Override
	protected void initMainView() {
		initTitle(R.drawable.btn_back_bg, R.string.notify_title, 0, 0);
		initComponents();
	}

	private void initComponents() {
		listView = (ListView) findViewById(R.id.listView1);
		listView.setCacheColorHint(Color.TRANSPARENT);
		adapter = new NotifyAdapter(this, PieMomentApp.getDataList());
		listView.setAdapter(adapter);
		
		tips_text = (TextView)findViewById(R.id.tips_text);
		
	}
	
	@Override
	protected void registerMainViewEvent() {
		
	}

	@Override
	protected void processMainView() {
		refreshUI();
	}


	public void refreshUI() {
		ArrayList<NotifyEntity> dataList = PieMomentApp.getDataList();
		if(dataList!=null&&dataList.size()>0) {
			listView.setVisibility(View.VISIBLE);
			tips_text.setVisibility(View.GONE);
			adapter = new NotifyAdapter(this, dataList);
			listView.setAdapter(adapter);
		}else {
			listView.setVisibility(View.GONE);
			tips_text.setVisibility(View.VISIBLE);
		}
		
	}
	
	@Override
	public void onClick(View v) {
		switch (v.getId()) {
		case R.id.btn_left:
			super.onBackPressed();
			break;
		default:
			break;
		}
	}

}
